#pragma once

#include <cstring>
#include <string>

#include "gtest/gtest.h"

#include "Utility/FileSystem/SGFileSystem.h"

// 获取当前工作路径测试
TEST (getWorkingDirectoryTest, CurrentWorkingDirectory)
{
#if defined(_WIN64) || defined(WIN32) || defined(_WIN32)
    // Input Data
    auto        cwd = SG::Utility::FileSystem::getWorkingDirectory ();
    const char* path{ "C:\\Users" };
    _chdir (path);

    // Test Data
    auto cwdTest = SG::Utility::FileSystem::getWorkingDirectory ();

    // 还原工作路径
    _chdir (cwd.c_str ());
#else
    // Input Data
    auto        cwd = SG::Utility::FileSystem::getWorkingDirectory ();
    const char* path{ "/home" };
    int         result = chdir (path);

    ASSERT_EQ (result, 0);
    // Test Data
    auto cwdTest = SG::Utility::FileSystem::getWorkingDirectory ();

    // 还原工作路径
    result = chdir (cwd.c_str ());

    ASSERT_EQ (result, 0);
#endif

    // Target Data
    const std::string cwdTarget = path;

    // Check
    ASSERT_EQ (cwdTarget, cwdTest);
}
